reverse of string in automata